﻿using System.Configuration;
using System.ServiceProcess;
using System.ComponentModel;


namespace BidNotifier
{
    [RunInstaller(true)]
    public class ProjectInstaller : System.Configuration.Install.Installer
    {
        private readonly string serviceName;
        private readonly ServiceInstaller serviceInstaller;
        private readonly ServiceProcessInstaller serviceProcessInstaller;

        public ProjectInstaller()
        {
            serviceName = ConfigurationManager.AppSettings["serviceName"] ?? "BidNotifyService";
           
            serviceProcessInstaller = new ServiceProcessInstaller();
           serviceInstaller = new ServiceInstaller();
            // 
            // serviceProcessInstaller
            // 
            serviceProcessInstaller.Account = ServiceAccount.LocalSystem;
            serviceProcessInstaller.Password = null;
            serviceProcessInstaller.Username = null;
            // 
            // serviceInstaller
            // 
            serviceInstaller.ServiceName = serviceName;
            serviceInstaller.StartType =ServiceStartMode.Automatic;
            // 
            // ProjectInstaller
            // 
            Installers.AddRange(new System.Configuration.Install.Installer[] {
            serviceProcessInstaller,
            serviceInstaller});
        }
    }
}
